package juc.thread.secuity;
/*
* wait notify
* */
public class Test7 {
    private static Object lock=new Object();
    public static void main(String[] args) throws InterruptedException {
           new Thread(()->{
               System.out.println("尝试1...");
               synchronized (lock){
                   try {
                       lock.wait();
                   } catch (InterruptedException e) {
                       e.printStackTrace();
                   }
               }
               System.out.println("结束1...");
           },"t1").start();
        new Thread(()->{
            System.out.println("尝试2...");
            synchronized (lock){
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("结束2...");
        },"t2").start();

        Thread.sleep(2000);
        synchronized (lock){
            System.out.println("唤醒...");
//            lock.notify();
              lock.notifyAll();
        }
    }
}
